# encoding:utf-8
import json,os,datetime,time
from flask import Flask, jsonify, request, render_template
from flask_cors import CORS
#from libs.alterData import *

# configuration
app = Flask(__name__)
app.config.from_object(__name__)
DEBUG = True
app.jinja_env.auto_reload = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
# enable CORS
CORS(app, resources={r'/*': {'origins': '*'}})

#静默数据查收
@app.route('/alarm/main/<silenceTime>', methods=['GET'])
def alarm_status(silenceTime):
    os.system('/bin/bash /app/shell/alarm/alarm_status.sh {}'.format(silenceTime))
    return jsonify(silenceTime)

#静默数据查收
@app.route('/alarm/process/<silenceTime>', methods=['GET'])
def alarm_process_status(silenceTime):
    # dtime = datetime.datetime.now()
    # un_time = time.mktime(dtime.timetuple())
    # os.system('echo {},{} >>/app/shell/alter/readfile/alterStatus.csv'.format(un_time,silenceTime))
    os.system('/bin/bash /app/alarm/shell/alarm_process_status.sh {}'.format(silenceTime))
    return jsonify(silenceTime)

if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0", port="60009")
